/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openbrew.openbrewrf;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author dchapman
 */
@Entity
@Table(name = "LabType")
@XmlRootElement
public class LabType implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "labTypeID")
    private Integer ltid;
    @Size(min = 0, max = 250)
    @Column(name = "labTypeDesc")
    private String ltdesc;
    @Basic(optional = false)
    @NotNull
    @Column(name = "labTypePerBrew")
    private boolean ltPerBrew;
    @JoinColumn(name = "labTypeProcessID", referencedColumnName = "labProcessID", nullable=true)
    @ManyToOne(optional = true)
    private LabProcess labProcess;
    
    @OneToMany(mappedBy = "labType")
    private Collection<BrewLabDetails> brewLabDetailsCollection;

    public LabType() {
    }

    public LabType(Integer ltid) {
        this.ltid = ltid;
    }

    public LabType(Integer ltid, String ltdesc, boolean ltPerBrew) {
        this.ltid = ltid;
        this.ltdesc = ltdesc;
        this.ltPerBrew = ltPerBrew;
    }

    public Integer getLtid() {
        return ltid;
    }

    public void setLtid(Integer ltid) {
        this.ltid = ltid;
    }

    public String getLtdesc() {
        return ltdesc;
    }

    public void setLtdesc(String ltdesc) {
        this.ltdesc = ltdesc;
    }

    public boolean isLtPerBrew() {
        return ltPerBrew;
    }

    public void setLtPerBrew(boolean ltPerBrew) {
        this.ltPerBrew = ltPerBrew;
    }

    public LabProcess getLabProcess() {
        return labProcess;
    }

    public void setLabProcess(LabProcess labProcess) {
        this.labProcess = labProcess;
    }

    @XmlTransient
    public Collection<BrewLabDetails> getBrewLabDetailsCollection() {
        return brewLabDetailsCollection;
    }

    public void setBrewLabDetailsCollection(Collection<BrewLabDetails> brewLabDetailsCollection) {
        this.brewLabDetailsCollection = brewLabDetailsCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ltid != null ? ltid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof LabType)) {
            return false;
        }
        LabType other = (LabType) object;
        if ((this.ltid == null && other.ltid != null) || (this.ltid != null && !this.ltid.equals(other.ltid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.LabType[ ltid=" + ltid + " ]";
    }
}
